package com.ls.demo.tcp.service.impl;

import com.ls.demo.bean.Command;
import com.ls.demo.tcp.service.CommandService;
import io.netty.channel.ChannelHandlerContext;
import org.springframework.stereotype.Service;

/**
 * @author liShan
 * @date 2019/8/31 10:09
 */
@Service("command_0A")
public class CommandHeartbeatImpl implements CommandService {

    @Override
    public Command execute(ChannelHandlerContext ctx, Command command) {
        try {
            Command c = command.clone();
            c.setTarAddrHigh(command.getSrcAddrHigh());
            c.setTarAddrLow(command.getSrcAddrLow());
            c.setSrcAddrHigh(command.getTarAddrHigh());
            c.setSrcAddrLow(command.getTarAddrLow());
            return c;
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
}
